<?php
namespace app\home\controller;

use FFMpeg;

class Test
{
    public function index()
    {
        $path = [
            'ffmpeg.binaries'  => '/usr/bin/avconv',
            'ffmpeg.binaries' => '/usr/bin/ffmpeg',
            'ffprobe.binaries' => '/usr/bin/avprobe',
            'ffprobe.binaries' => '/usr/bin/ffprobe',
        ];
        
        $ffmpeg = FFMpeg\FFMpeg::create($path);
        $v1080 = 'http://jr1test.oss-cn-beijing.aliyuncs.com/upload/202009/5f65c001e2a8b.mp4';

        $video = $ffmpeg->open($v1080);
        //提取第几秒的图像
        for ($i=1; $i <= 10; $i++) { 
            $frame = $video->frame(FFMpeg\Coordinate\TimeCode::fromSeconds($i));
            $frame->save(root_path()."public/static/image/ffmpeg/img_$i.jpg");
        }
        var_dump("成功了啊");die;
    }
}
